package lex.proxyverfier.verifier;

import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.Future;
import java.util.concurrent.SynchronousQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class ThreadPool
{
	private static final ThreadPoolExecutor pool;
	static
	{
		//core=5; max=100; keepAliveTime=60s
		pool = new ThreadPoolExecutor( 5, 100, 30L, TimeUnit.SECONDS,
			new SynchronousQueue<Runnable>() );
	}

	private ThreadPool()
	{
		super();
	}

	public static synchronized void execute( Runnable command )
	{
		pool.execute( command );
	}

	public static synchronized <T> Future<T> submit( Callable<T> task )
	{
		return pool.submit( task );
	}

	//====================================
	public static void shutdown()
	{
		pool.shutdown();
	}

	public static List<Runnable> shutdownNow()
	{
		return pool.shutdownNow();
	}

	public static int active()
	{
		return pool.getActiveCount();
	}

	public static int size()
	{
		return pool.getPoolSize();
	}
}
